
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 500px;
            height: 500px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div></div>
    <button>解绑</button>
    <script>
        var div = document.querySelector("div")
        var btn = document.querySelector("button")

        //绑定事件
        // div.onclick = fn
        // function fn(){
        //     console.log("DOM0 click");
        // }
        // //解绑事件
        // btn.onclick = function(){
        //     //DOM0的解绑事件
        //     div.onclick = null;
        // }

        // DOM2
        div.addEventListener("click",fn1)
        div.addEventListener("click",fn2)
        function fn1(){
            console.log("DOM2 click 11111111111111");
        }
        function fn2(){
            console.log("DOM2 click 22222222222222");
        }

        //解绑
        btn.onclick = function(){
            //解绑
            div.removeEventListener("click",fn1)
        }
    </script>
</body>
</html>